package com.zzyl.nursing.task;

import com.zzyl.nursing.domain.CheckIn;
import com.zzyl.nursing.domain.Contract;

import com.zzyl.nursing.mapper.ContractMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Component
public class DemoTask {
    @Autowired
    private ContractMapper contractMapper;
    @Scheduled(cron="0 0 1 * * ?")
    public void task(){
        List<Contract> contracts = contractMapper.selectList(null);
        // 示例：从List中获取满足条件的元素startDate
        contracts.forEach(contract -> {
            if (contract.getStartDate() != null && contract.getStartDate().isAfter(LocalDateTime.now())) {

                    log.info("合同{}有效", contract.getId());
            }
        });

    }

}
